{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <div class="row cl">
            <div class="formControls col-xs-6 col-sm-6">
                <script id="editor" type="text/plain" name="content">{$hotel.content}</script>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-primary radius" id="tijiao">&nbsp;&nbsp;保存&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="style"}
<link rel="stylesheet" href="__LIB__/lightbox2/css/lightbox.min.css">
{/block}
{block name="script"}
<script src="__LIB__/lightbox2/js/lightbox.min.js"></script>
<script>window.UEDITOR_HOME_URL = '__LIB__/ueditor/1.4.3/'</script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script>
    $(function () {
        var ue = UE.getEditor('editor',{
            serverUrl:'{:\\think\\Url::build("Ueditor/index")}',
            imageFieldName: 'img'
        });
        $('#tijiao').on('click', function () {
            var index = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });
            var html = ue.getContent();
            html = encodeURIComponent(html);
            var data = {
                content: html
            };
            $.ajax({
                url: '/admin/hotel/add',
                type: 'post',
                dataType: 'json',
                data: {data: data},
                success: function (res) {
                    if (res.code === 0) {
                        layer.msg('保存成功', function () {
                            layer_close();
                        });
                    }
                }
            });
        });
    })
</script>
{/block}